
import javax.swing.BoxLayout;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;
import java.util.ListIterator;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import java.util.Date;

import calendar_ex.*;
import calendar_ex.Appointment.Recurrence;
import javax.swing.Box;
import javax.swing.Box.Filler;

import panels.Inner;
import panels.SwipeButtons;

import views.*;
import functions.*;

public class CalendarTest extends JFrame implements ActionListener, WindowListener{
	
	/* GIVEN VARIABLES AND DEFINITIONS */
	private final String NEXT_COMMAND = "NEXT";
	private final String PREV_COMMAND = "PREV";
	
	CalendarEx cal;
	JTextField start_day_tf, end_day_tf, start_month_tf, end_month_tf,
		start_year_tf, end_year_tf, id_tf;
	
	JTextField id, date, month, year, start_time, end_time, recurs, description, location, category, reminder;

	List<Appointment> aps;
	ListIterator<Appointment> aps_it;
	
	JButton but, add_but, del_but;

	/* END OF GIVEN VARIABLES AND DEFINITIONS */
	public CalendarTest(){
		/* Set up the Calendar Exercise */
		cal = new CalendarEx();
		cal.openCalendar("./calendar.txt");	
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		/* End of Set up Calendar Exercise */
		
		/* START OF OUTER PANE WORK */
		Container outer = getContentPane();
		/* USE BORDER LAYOUT FOR OUTER */
		outer.setLayout(new BorderLayout());
		/* DEFINE SWIPE BUTTONS and ADD TO OUTER SHELL */
		SwipeButtons swipeButtons = new SwipeButtons();
		outer.add(swipeButtons.getSwipe(0),BorderLayout.NORTH);
		outer.add(swipeButtons.getSwipe(1),BorderLayout.EAST);
		outer.add(swipeButtons.getSwipe(2),BorderLayout.SOUTH);
		outer.add(swipeButtons.getSwipe(3),BorderLayout.WEST);
		/* SET OUTER FRAME DIMENSIONS */
		int outerWidth = 100+360+100;
		int outerHeight= 50+600+50;
		outer.setPreferredSize(new Dimension(outerWidth,outerHeight));
		/* SET OUTER BACKGROUND COLOR */
		outer.setBackground(Color.WHITE);
		/* END OF OUTER PANE WORK */
		
		JPanel inner = new Inner();
		
		/* ADD INNER PANEL TO OUTER CENTER */
		outer.add(inner,BorderLayout.CENTER);
		/* PACK JFRAME AND SET VISIBLE */
		pack();
		setVisible(true);
	}
	public static void main(String[] args){
		
		
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (UnsupportedLookAndFeelException e) {
			e.printStackTrace();
		}
		
		CalendarTest ct = new CalendarTest();
	}
	@Override
	public void windowOpened(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void windowClosing(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void windowClosed(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void windowIconified(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void windowDeiconified(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void windowActivated(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void windowDeactivated(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		
	}

}